package cn.hxzy.service.impl;

import cn.hxzy.domain.Video;
import cn.hxzy.mapper.VideoMapper;
import cn.hxzy.service.VideoService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VideoServiceImpl  extends ServiceImpl<VideoMapper, Video> implements VideoService{
    @Autowired
    private VideoMapper videoMapper;



    //查询当前小结视频
    @Override
    public List<Video> getVideoListBySectionId(Long id) {
        QueryWrapper<Video> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("section_id",id);
        List<Video> videos = videoMapper.selectList(queryWrapper);
        return videos;
    }

    //删除视频
    @Override
    public Boolean deleteVideo(Long id) {
        int delete = videoMapper.deleteById(id);
        if (delete>0){
            return true;
        }
        return false;
    }

    //批量删除
    @Override
    public Boolean deleteVideoBatch(Long[] ids) {
        for (int i = 0; i < ids.length; i++) {
            //遍历出来循环删除
            videoMapper.deleteById(ids[i]);

        }
        return true;
    }
}
